<ul class="nav sidebar-menu">
  <?php foreach ($sidebar_menu as $item): ?>
      <li class="<?php echo ($item->link->active == 1) ? ((!empty($item->children)) ? 'open' : 'active') : ''; ?>">
          <a href="<?php echo empty($item->link->url_alias) ? '#' : $item->link->url_alias; ?>"
             class="<?php echo empty($item->link->url_alias) ? 'menu-dropdown' : ''; ?>">
              <i class="menu-icon <?php echo $item->link->class; ?>"></i>
              <span class="menu-text"> <?php echo $item->link->title; ?> </span>
            <?php if (!empty($item->children)): ?>
                <i class="menu-expand"></i>
            <?php endif; ?>
          </a>

        <?php if (!empty($item->children)): ?>

            <ul class="submenu" style="display: none;">
              <?php foreach ($item->children as $child): ?>
                  <li class="<?php echo ($child->link->active == 1) ? 'active' : ''; ?>">
                      <a href="<?php echo $child->link->url_alias; ?>">
                          <span class="menu-text"> <?php echo $child->link->title; ?> </span>
                      </a>
                  </li>
              <?php endforeach; ?>
            </ul>
        <?php endif; ?>
      </li>
  <?php endforeach; ?>
</ul>